import { Component, Input, Output, EventEmitter, SimpleChanges } from '@angular/core';

import { Hero, ComponentBase, ReinitializableComponentBase } from '../share';

@Component({
    selector: 'reinitialize-component',
    templateUrl: './reinitialize.component.html'
})
export class ReinitializeComponent extends ReinitializableComponentBase {
    @Input() hero: Hero;

    ngOnInit() {
        super.ngOnInit();
        this.initialize();
    }

    ngOnChanges(changes: SimpleChanges) {
        super.ngOnChanges(changes);
    }

    ngDoCheck() {
        let isReinitialized = super.prepareToReinitialize();
        if (isReinitialized)
            return;

        super.ngDoCheck();
    }

    protected initialize(): void {
        this.internalConsoleLog(`internalinitialize on ${this.toBeReinitialize}`);
    }
}